/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movie.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author admin
 */
@Entity
@Table(name = "genre")
@NamedQueries({
	@NamedQuery(name = "Genre.findAll", query = "SELECT g FROM Genre g")})
public class Genre implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_genre")
	private Integer idGenre;
	@Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "name")
	private String name;
	@Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
	private String description;
	@ManyToMany(mappedBy = "genreList", fetch = FetchType.LAZY)
	private List<Film> filmList;

	public Genre() {
	}

	public Genre(Integer idGenre) {
		this.idGenre = idGenre;
	}

	public Genre(Integer idGenre, String name, String description) {
		this.idGenre = idGenre;
		this.name = name;
		this.description = description;
	}

	public Integer getIdGenre() {
		return idGenre;
	}

	public void setIdGenre(Integer idGenre) {
		this.idGenre = idGenre;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<Film> getFilmList() {
		return filmList;
	}

	public void setFilmList(List<Film> filmList) {
		this.filmList = filmList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (idGenre != null ? idGenre.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Genre)) {
			return false;
		}
		Genre other = (Genre) object;
		if ((this.idGenre == null && other.idGenre != null) || (this.idGenre != null && !this.idGenre.equals(other.idGenre))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "movie.entity.Genre[ idGenre=" + idGenre + " ]";
	}
	
}
